# Maintainer: Frederic Wang <fred.wang@free.fr>

_realname=idna
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.0
pkgrel=1
pkgdesc='Internationalized Domain Names in Applications (mingw-w64)'
url='https://github.com/kjd/idna'
license=('BSD-like')
arch=('any')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python3")
source=("https://pypi.python.org/packages/source/i/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('16199aad938b290f5be1057c0e1efc6546229391c23cea61ca940c115f7d3d3b')

prepare() {
  cd ${srcdir}
  cp -r ${_realname}-${pkgver} build-python2
  cp -r ${_realname}-${pkgver} build-python3
}

package_python3-idna() {
  cd ${srcdir}/build-python3
  ${MINGW_PREFIX}/bin/python3 setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE.rst" "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-idna() {
  cd ${srcdir}/build-python2
  ${MINGW_PREFIX}/bin/python2 setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE.rst" "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-idna() {
  package_python2-idna
}

package_mingw-w64-i686-python3-idna() {
  package_python3-idna
}

package_mingw-w64-x86_64-python2-idna() {
  package_python2-idna
}

package_mingw-w64-x86_64-python3-idna() {
  package_python3-idna
}
